<div>
    <div class="col-lg-12">
        <section class="panel">
            <div class="panel-body">
                <form class="form-horizontal adminex-form" onsubmit="return false;">
                    <div class="base">
                        <div class="base-left">
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><span class="red-start">*</span> 原始密码</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" name="password_old" placeholder="请输入原始密码"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><span class="red-start">*</span> 新密码</label>
                                <div class="col-lg-4">
                                    <div class="input-group" style="width: 100%;">
                                        <input type="password" class="form-control" name="password_new" placeholder="请输入新密码">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><span class="red-start">*</span> 确认密码</label>
                                <div class="col-lg-4">
                                    <div class="input-group" style="width: 100%;">
                                        <input type="password" class="form-control" name="password_again" placeholder="请输入确认密码">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div style="clear: both"></div>
                    <div style="margin-top: 50px;"></div>

                    <div class="form-group">
                        <div class="modal-footer" style="text-align: left;margin-left: 6%;">
                            <button class="btn btn-success" type="button" onclick="save();">保存</button>
                            <button class="btn btn-success" type="button" style="background-color:#CCCCCC;border-color:#CCCCCC;" data-dismiss="modal" aria-hidden="true">
                                <a href="#" onclick="window.history.back()" style="text-decoration: none;">取消</a></button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>
<script type="text/javascript">
    function save() {
        password_old = $('input[name=password_old]').val();
        password_new = $('input[name=password_new]').val();
        password_again = $('input[name=password_again]').val();

        if (password_old == '') {
            msg.error('原始密码不能为空');
            return;
        }
        if (password_new == '') {
            msg.error('新密码不能为空');
            return;
        }
        if (password_again == '') {
            msg.error('确认密码不能为空');
            return;
        }
        if (password_new != password_again) {
            msg.error('新密码和确认密码不相同');
            return;
        }

        var index = layer.msg('保存中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '0px', time:1000000});
        $.ajax({
            url  : '/my/index',
            type : 'post',
            data : {password_old:password_old,password_new:password_new,password_again:password_again},
            dataType : 'json',
            success : function (msg) {
                if (msg.code == 200) {
                    layer.close(index);
                    layer.alert('修改成功',function () {
                        location.href = '/login/out';
                    })
                } else{
                    layer.close(index);
                    layer.alert(msg.message);
                }
            }
        });
    }
</script>